<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>

	<body>
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
	
			<ul class="breadcrumb">
				<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
				<li>订单管理</li>
				<li class="active">列表</li>
			</ul>
			<!-- .breadcrumb -->
		</div>
		
		<div class="page-content">
				<div class="page-header">
					<h1>订单管理
						<small>
						<i class="icon-double-angle-right"></i>
						查看
						</small>					
					</h1>			
				</div>
				
				<div>
				<form  id="searchOrderForm" name="searchOrderForm" role="form" method="post" action="${ctx}/sys/order/order_list">
					<input type="text" id="orderCode" name="orderCode" placeholder="订单编号" value="${searchOrderForm.orderCode}" class="col-xs-10 col-sm-2"/>
					<label for="form-field-select-3" style="width:40px;margin-left: 20px" for="orderCode">科目 </label>
					<select  id="subjectId" name="subjectId" data-placeholder="请选择科目">
						<option value="">请选择科目</option>
						<option value="1" <c:if test="${searchOrderForm.subjectId eq '1'}">selected</c:if> >语文</option>
						<option value="2" <c:if test="${searchOrderForm.subjectId eq '2'}">selected</c:if> >数学</option>
						<option value="3" <c:if test="${searchOrderForm.subjectId eq '3'}">selected</c:if> >英语</option>
					</select>
					
					<label for="form-field-select-3" style="width:70px;margin-left: 20px" for="orderCode">起止时间 </label>
					
					<input class="date-picker" id="id-date-picker-1" name="startDate" type="text" width="100px" data-date-format="yyyy-mm-dd" placeholder="开始时间" value="${startDate}"/>
					<span  width="40px"><i class="icon-calendar bigger-110"></i></span>	
					-
					<input class="date-picker" id="id-date-picker-2" name="endDate" type="text" width="100px" data-date-format="yyyy-mm-dd" placeholder="结束时间" value="${endDate}"/>
					<span  width="40px"><i class="icon-calendar bigger-110"></i></span>
					
					<label for="form-field-select-3" style="width:40px;margin-left: 20px" for="orderCode">状态 </label>
					<select  id="status" name="status" data-placeholder="请选择状态">
						<option value="">请选择状态</option>
						<option value="1"  <c:if test="${searchOrderForm.status eq '1'}">selected</c:if> >未支付</option>
						<option value="3"  <c:if test="${searchOrderForm.status eq '3'}">selected</c:if> >已支付</option>
					</select>
															
					<input id="sysUserInfoSearch" type="submit" value="查询" style="margin-left: 10px">
					
				</form>				
				</div>
				
				<div style="line-height: 10px;">&nbsp;</div>
				
				<div class="row" >
				<div class="col-xs-12">
				<table id="simple-table" class="table table-striped table-bordered table-hover"  style="margin-top:5px;">
							<thead>
								<tr>
									<th class="center" style="width: 30px;">
										<label><input class="ace" type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
									</th>
									<th class='center' style="width:50px;">序号</th>
									<th class="center">订单编号</th>
									<th class="center">姓名</th>
									<th class="center">科目</th>
									<th class="center">商品</th>
									<th class="center">下单时间</th>
									<th class="center">订单金额</th>
									<th class="center">邮箱</th>
									<th class="center">手机号</th>
									<th class="center">状态</th>
									<th class="center" >操作</th>
								</tr>
							</thead>
												
							<tbody id="orderlist">
							<c:forEach var="res" items="${res.data.rows}" varStatus="status">
								<tr  id="orderinfo_row_${res.id}" >
									<td class="center">
										<label><input type="checkbox" class="ace" /><span class="lbl"></span></label>
									</td>
									<td class="center" title="${res.id}">&nbsp;${status.index+1}</td>
									<td class="center"><a href="#">${res.orderCode}</a></td>
									<td class="center">${res.userName}</td>
									<td class="center">
										<c:choose>
					                 		<c:when test="${res.subjectId==1}">语文</c:when>
					                 		<c:when test="${res.subjectId==2}">数学</c:when>
					                 		<c:when test="${res.subjectId==3}">英语</c:when>
					                 	</c:choose>
									</td>
									<td class="center">${res.goodsId}</td>
									<td class="center"> <fmt:formatDate value="${res.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
									<td class="center"> <fmt:formatNumber value="${res.orderPrice}"  type="CURRENCY"/></td>
									<td class="center">${res.orderEmail}</td>
									<td class="center">${res.orderPhone}</td>
									<td class="center">
										<c:choose>
					                 		<c:when test="${res.status==1}">未支付</c:when>
					                 		<c:when test="${res.status==2}">待支付</c:when>
					                 		<c:when test="${res.status==3}">已支付</c:when>
					                 		<c:when test="${res.status==-1}">已取消</c:when>
					                 	</c:choose>
									</td>
									<td class="center">
										<button class="btn btn-xs btn-info" onclick="location='' ">
											<i class="icon-edit bigger-120"></i>
										</button>
										
										<button class="btn btn-xs btn-danger" onclick="javascript:deleteOrder(${res.id});">
											<i class="icon-trash bigger-120"></i>
										</button>
									</td>
								</tr>
							</c:forEach>
				</table>
				<%@ include file="/WEB-INF/views/decorators/page.jsp"%> 
				</div>
				</div>
				
			</div>
			
			<script type="text/javascript">
			jQuery(function($) {
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
				
				$('.date-picker').datepicker({autoclose:true}).next().on(ace.click_event, function(){
					$(this).prev().focus();
				});
			})
			
			function deleteOrder(orderId){
				if(confirm("您确认删除该条记录吗?")){
					//resetRowById(userId);
					$.ajax({
						type : "DELETE",
						dataType: "json",
						async: false,
						url: '${ctx}/sys/order/delete/'+orderId,
						success: function (data) {
									if(data!=undefined&&data.status!=undefined&&data.status.trim()=="0"){
										$("#orderinfo_row_"+orderId).remove();
										alert("删除成功。");
									}else{
										alert("error:"+data.error);
									}
								 },
						error: function(data) {
									alert("删除失败。");
								}
					});
					return false;
				}
			}
			
			
			</script>
	</body>

</html>
